<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
    <link rel="stylesheet" href="css/tourAround.css">
    <link rel="stylesheet" href="css/swiper.min.css">
    <title>郑州周边游-游侠客</title>
</head>

<body>
    <div class="around_channel">
        <p class="title">郑州周边游</p>
        <div class="input">
            <img src="img/search_icon.png" alt="">
            <p>搜索目的地/关键词</p>
        </div>
        <img class="station" src="https://qimg4.youxiake.com/upload/202409/27/f76e0d7e0f3fe66f.jpg" alt="">
        <div class="banner1">
            <div class="swiper-container">
                <div class="swiper-wrapper"></div>

            </div>
            <img width="12" height="12" src="https://m.youxiake.com/20250822191430/img/arrow02.b695ebb7.png" alt="">
        </div>
    </div>
    <div class="plate">
        <div class="plate-left">
            <img class="action" src="https://m.youxiake.com/20250822191430/img/hdrl.9abd56c1.png" alt="">
            <p class="look">查看近期出发活动</p>
            <p class="GO">GO</p>
            <img class="today size1" src="img/rili.png" alt="">
        </div>
        <div class="plate-right">
            <div class="plate-right-top">
                <img class="action" src="https://m.youxiake.com/20250822191430/img/bzxc.2ba379d4.png" alt="">
                <p class="look">躲进小镇的时光</p>
                <img class="today size2" src="img/lou.png" alt="">
            </div>
            <div class="plate-right-bottom">
                <img class="action" src="https://m.youxiake.com/20250822191430/img/cszb.5799a0bc.png" alt="">
                <p class="look">躲进小镇的时光</p>
                <img class="today size3" src="img/dingwei.png" alt="">
            </div>
        </div>
    </div>
    <div class="navss">
        <div class="navs">
            <div class="navs-left">
                <p class="active">人气尖货</p>
                <p>人气新品</p>
                <p>人气多日</p>
            </div>
            <div class="navs-right">
                <p class="more">更多</p>
                <img class="more-icon" src="https://m.youxiake.com/20250822191430/img/arrow01.c5fc1ec3.png" alt="">
            </div>
        </div>
    </div>
    <ul class="renqi">
        <li>
            <div class="renqi-img">
                <img src="https://gallery.youxiake.com/product/line/202508/19/17555994017567DHYL.jpg?imageMogr2/auto-orient/gravity/Center/crop/1000x750/blur/1x0/quality/100"
                    alt="">
                <p class="baoming">201人已报名</p>
                <p class="renqi-top1">TOP 1</p>
            </div>
            <div class="renqi-bottom">
                <p class="renqi-p1">徒步登山·郑州出发</p>
                <p class="renqi-p2">勇攀·十字岭</p>
                <div class="money">
                    <p class="money-p1">
                        <span class="money-span1">￥</span>
                        <span class="money-span2">108</span>
                        <span class="money-span3">起</span>
                    </p>
                    <p class="money-p2">1天</p>
                </div>
            </div>
        </li>
        <li>
            <div class="renqi-img">
                <img src="https://gallery.youxiake.com/product/line/202408/20/1724117206348r7X1r.jpg?imageMogr2/auto-orient/gravity/Center/crop/750x563/blur/1x0/quality/100"
                    alt="">
                <p class="baoming">377人已报名</p>
                <p class="renqi-top2">TOP 2</p>
            </div>
            <div class="renqi-bottom">
                <p class="renqi-p1">徒步登山·郑州出发</p>
                <p class="renqi-p2">蟒河休闲玩水</p>
                <div class="money">
                    <p class="money-p1">
                        <span class="money-span1">￥</span>
                        <span class="money-span2">108</span>
                        <span class="money-span3">起</span>
                    </p>
                    <p class="money-p2">1天</p>
                </div>
            </div>
        </li>
        <li>
            <div class="renqi-img">
                <img src="https://gallery.youxiake.com/product/line/202501/22/1737549307092kT4cw.jpg?imageMogr2/auto-orient/gravity/Center/crop/750x563/blur/1x0/quality/100"
                    alt="">
                <p class="baoming">16人已报名</p>
                <p class="renqi-top3">TOP 3</p>
            </div>
            <div class="renqi-bottom">
                <p class="renqi-p1">徒步登山·郑州出发</p>
                <p class="renqi-p2">黄河滩草原骑马</p>
                <div class="money">
                    <p class="money-p1">
                        <span class="money-span1">￥</span>
                        <span class="money-span2">199</span>
                        <span class="money-span3">起</span>
                    </p>
                    <p class="money-p2">1天</p>
                </div>
            </div>
        </li>
        <li>
            <div class="renqi-img">
                <img src="https://gallery.youxiake.com/product/line/202409/10/1725968223142GkRa1.jpg?imageMogr2/auto-orient/gravity/Center/crop/750x563/blur/1x0/quality/100"
                    alt="">
                <p class="baoming">206人已报名</p>
                <p class="renqi-top4">TOP 4</p>
            </div>
            <div class="renqi-bottom">
                <p class="renqi-p1">徒步登山·郑州出发</p>
                <p class="renqi-p2">人间仙境罗姐寨</p>
                <div class="money">
                    <p class="money-p1">
                        <span class="money-span1">￥</span>
                        <span class="money-span2">108</span>
                        <span class="money-span3">起</span>
                    </p>
                    <p class="money-p2">1天</p>
                </div>
            </div>
        </li>
    </ul>
    <div class="navss">
        <div class="navs">
            <div class="navs-left">
                <p class="active">区域长线</p>
                <p>口碑精选</p>
            </div>
        </div>
    </div>
    <ul class="renqi2">
    </ul>
    <div class="guide">
        <p class="guide-title">郑州活跃领队</p>
        <ul class="guide-list">

        </ul>
    </div>
    <div class="card1">
        <h3 class="card_tit"></h3>
        <span>每周一次免费旅行 线路装备专享折扣</span>
        <div class="card_btn">立即开通</div>
        <i class="tag">未获得</i>
        <i class="icon"></i>
    </div>
    <ul class="waterfall__type__nav">
        <li>精选推荐</li>
        <li>户外游</li>
        <li>亲子游</li>
        <li>摄影游</li>
    </ul>
    <ul class="product-days">
        <li class="actived">不限</li>
        <li>1天</li>
        <li>2天</li>
        <li>3天</li>
        <li>3天以上</li>
    </ul>
    <ul class="go">
    </ul>
</body>
<script src="js/reset.js"></script>
<script src="js/swiper.min.js"></script>
<script>
    // 添加时间转换函数：将时间转换为"多少小时前"格式
    function formatTimeAgo(publishTime) {
        // 处理可能的时间格式问题，移除毫秒部分
        const cleanTime = publishTime.split('.')[0];
        const publishDate = new Date(cleanTime);
        const now = new Date();

        // 计算时间差（毫秒）
        const diffMs = now - publishDate;
        // 转换为小时
        const diffHours = Math.floor(diffMs / (1000 * 60 * 60));

        // 格式化显示
        if (diffHours < 1) {
            return "刚刚"; // 小于1小时显示"刚刚"
        } else if (diffHours < 24) {
            return `${diffHours}小时前`;
        } else {
            // 超过24小时显示天数
            const diffDays = Math.floor(diffHours / 24);
            return `${diffDays}天前`;
        }
    }

    fetch('https://m.youxiake.com/api/m/channel/around/v2?sitecode=39').then(res => res.json()).then(res1 => {
        console.log(res1);
        const swiperWrapper = document.querySelector('.banner1 .swiper-wrapper');
        const guideList = document.querySelector('.guide-list');
        // 清空现有内容
        swiperWrapper.innerHTML = '';

        res1.data.enrollOrderUserList.forEach(item => {
            // 调用时间转换函数处理发布时间
            const timeAgo = formatTimeAgo(item.enrollTime);
            const genderIcon = item.sex === 0
                ? 'https://m.youxiake.com/20250905172021/img/nv.0362395f.png'  // 0显示女性图标
                : 'https://m.youxiake.com/20250905172021/img/nan.cc4da619.png';
            const cardHtml = item.useCard === 1
                ? '<p class="card">权益卡</p>'  // 有内容时带背景类
                : '';
            // 使用+=添加多个轮播项，而不是=覆盖
            swiperWrapper.innerHTML += `
                <div class="swiper-slide">
                    <div class="banner1-left">
                        <div class="heads">
                            <img class="head"
                                src="${item.avatar}"
                                alt="${item.nickname}的头像">
                            <img class="head-icon" src="${genderIcon}" alt="性别标识">
                        </div>
                        <p class="person-do"><span>${item.nickname}</span>｜${item.description}</p>
                        ${cardHtml}
                    </div>
                    <div class="banner1-right">
                        ${timeAgo} <!-- 使用转换后的时间 -->
                    </div>
                </div>
            `;
            guideList.innerHTML += `
            <li>
                <div class="guide-head">
                    <img src="${item.avatar}" alt="">
                </div>
                <div class="guide-info">
                    <p class="guide-name">${item.nickname}</p>
                    <img class="guide-icon" src="${genderIcon}" alt="">
                </div>
            </li>
           `
        });

        // 在数据加载完成后初始化轮播
        var swiper = new Swiper('.banner1 .swiper-container', {
            paginationClickable: true,
            direction: 'vertical',
            autoplay: 2500,
            autoplayDisableOnInteraction: false,
            loop: true
        });
        const renqi2 = document.querySelector('.renqi2');
        renqi2.innerHTML += `
            <li>
                <div class="renqi-img">
                    <img src="${item.image}"
                    alt="">
                    <p class="baoming">${item.numLabel}</p>
                </div>
                <div class="renqi-bottom">
                    <p class="renqi-p1">${item.productCat}·${item.placeLabel}</p>
                    <p class="renqi-p2">${item.title}</p>
                    <div class="money">
                        <p class="money-p1">
                            <span class="money-span1">￥</span>
                            <span class="money-span2">${item.priceLabel}</span>
                            <span class="money-span3">起</span>
                        </p>
                        <p class="money-p2">${item.days}</p>
                    </div>
                </div>
            </li>
            `
    }).catch(err => {
        console.error('数据请求失败:', err);
    });
    fetch('https://m.youxiake.com/api/m/channel/around/flow?sitecode=39&city_id=39&firstType=608&secondType=&page=&spm=').then(res => res.json()).then(res1 => {
        console.log(res1);
        const go = document.querySelector('.go');
        res1.data.data.list.forEach(item => {
            const detail = item.dataDetail;
        
        // 1. 正确定义 zaoniao（移到循环内，用字符串拼接，增加安全判断）
        const zaoniao = detail.manjian_early?.[0]?.detailRemark === '满6人减300'
          ? `<span class="discount">${detail.manjian_early[0].detailRemark}</span>`
          : '';

        // 2. 处理亮点数组（转为字符串）
        const liangdian = Array.isArray(detail.liangdian) ? detail.liangdian.join('、') : '';
            go.innerHTML += `
            <li>
            <div class="go__img">
                <img src="${item.dataDetail.image}" alt=""
                    onerror="this.src='默认图地址'">
                <p class="gosp">${item.dataDetail.placeLabel}</p>
            </div>
            <p class="gotype">
                <span>${item.dataDetail.productType} •</span>
                <span>${item.dataDetail.productCat} •</span>
                <span>${item.dataDetail.days}</span>
            </p>
            <p class="gotitle">${item.dataDetail.title}</p>
            <p class="tags">
                ${zaoniao}
              ${liangdian ? `<span class="tag">${liangdian}</span>` : ''}
            </p>
            <div class="price__content">
                <div class="price">￥<span>${item.dataDetail.priceLabel}</span>起</div>
                <div class="enroll__num">${item.dataDetail.numLabel}</div>
            </div>
        </li>
            `
        })
    }).catch(err => {
        console.log(err)
    })
</script>


</html>